<template>
  <div id="app">
    <audio id="myAudio" @canplay="canPlay" :src="src" ref="audio"></audio>
    <top-bar></top-bar>
    <router-view></router-view>
    <bottom-bar></bottom-bar>
    <sheet-detail></sheet-detail>
    <bottom-menu></bottom-menu>
    <bottom-music></bottom-music>
  </div>
</template>

<script>
import topBar from '@/components/topBar/topBar.vue'
import bottomBar from '@/components/bottomBar/bottomBar.vue'
import sheetDetail from '@/components/sheetDetail/sheetDetail'
import bottomMenu from '@/components/bottomMenu/bottomMenu'
import bottomMusic from '@/components/bottomMusic/bottomMusic'
import store from './store'
export default {
  name: 'App',
  components:{
    'top-bar':topBar,
    'bottom-bar':bottomBar,
    'sheet-detail':sheetDetail,
    'bottom-menu':bottomMenu,
    'bottom-music':bottomMusic,
  },
  computed:{
    src(){
      console.log(store.audioInfo);
      return store.getters.getCurMusic.url;
    }
  },
  methods:{
    canPlay(){
      console.log('can')
    }
  },
  created(){
    let LocalAPI = '../static/data.json';
    store.dispatch('set_AudioEle',this.$refs.audio);
    this.$http.get(LocalAPI).then((res) => {
      store.dispatch('set_musicList',res.data.music.all);
      store.dispatch('set_Sheets',res.data.music.sheets);
      store.dispatch('set_AudioEle', this.$refs.audio);
      store.dispatch('updateCurmusic',1);
    }, (err) => {
      alert(err)
    })
  }
}
</script>

<style  lang="scss">
@import '../static/style/public';
@import '../static/font-icon/style.css';

html,body,p{
  padding:0px;
  margin:0px;
}
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #cccccc;
}
</style>
